package com.leadership.entity.certificate;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.leadership.entity.user.User;

/**
 * 学员认证
 * @author haiyan_xiao
 *
 */
@Entity
@Table(name = "certificate_record")
public class CertificateRecord {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**
     * 学员邮箱
     */
    private String email;
    
    /**
     * 学员
     */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    private User user;
    
    /**
     * 认证
     */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Certificate certificate;
    
    /**
     * 创建时间
     */
    private Date createTime;
    
    /**
     * 更新时间
     */
    private Date updateTime;
    
    /**
     * 认证时间
     */
    private Date certificateTime;
    
    /** project Id */
    private Long currentProjectId;
    
    /**
     * 等级
     */
    @Enumerated(EnumType.ORDINAL)
    private CertificateLevel level;
    
    public CertificateRecord() {
        
    }
    
    public CertificateRecord(User user, Certificate certificate, Date certificateTime, Long projectId) {
        this.user = user;
        this.email = user.getEmail();
        this.certificate = certificate;
        this.createTime = new Date();
        this.updateTime = new Date();
        this.certificateTime = certificateTime;
        this.currentProjectId = projectId;
        this.level = CertificateLevel.A;
    }
    
    /**
     * 
     * @param certificateTime
     * @return
     */
    public CertificateRecord update(Date certificateTime) {
        this.certificateTime = certificateTime;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }

    /**
     * @return the certificate
     */
    public Certificate getCertificate() {
        return certificate;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the updateTime
     */
    public Date getUpdateTime() {
        return updateTime;
    }

    /**
     * @return the certificateTime
     */
    public Date getCertificateTime() {
        return certificateTime;
    }

    /**
     * @return the currentProjectId
     */
    public Long getCurrentProjectId() {
        return currentProjectId;
    }

    /**
     * @return the level
     */
    public CertificateLevel getLevel() {
        return level;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * @param certificate the certificate to set
     */
    public void setCertificate(Certificate certificate) {
        this.certificate = certificate;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param updateTime the updateTime to set
     */
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * @param certificateTime the certificateTime to set
     */
    public void setCertificateTime(Date certificateTime) {
        this.certificateTime = certificateTime;
    }

    /**
     * @param currentProjectId the currentProjectId to set
     */
    public void setCurrentProjectId(Long currentProjectId) {
        this.currentProjectId = currentProjectId;
    }

    /**
     * @param level the level to set
     */
    public void setLevel(CertificateLevel level) {
        this.level = level;
    }
}
